<template>
    <div class="administrativeOffice-print-class">
        <applyFor v-if="tableType == '行政'" :printList="printList" :qmImgList="qmImgList"/>
    </div>
</template>
<script>
import applyFor from '../applyFor/tableModule'

import {
    pidgetlchj,
    downMyQm,
    getMoreUserSignLinkList
} from './service/index'
export default {
    components:{
        applyFor,
    },
    props:{
        tableType:{
            type:String,
            default: '',
            required:false
        },
        printList:{
            type:[Array,Object],
            default: () => {},
            required:false
        },
        // qmImgList:{
        //     type:[Array,Object],
        //     default: () => {},
        //     required:false
        // }
    },
    data(){
        return{
            // printList: [],
            qmImgList: [],
            tableTypeList: [
                '行政','出差'
            ]
        }
    },
    watch:{
        printList: {
            handler (newval, oldVal) {
                if(newval.length){
                    this.getImg(newval)
                }
            },
            immediate: true,
            deep: true
        },
    },
    mounted(){
        //console.log('打印组件',this.printList,this.qmImgList)
    },
    methods:{
        getImg(list){
            list.forEach((itemA,index) => {
                pidgetlchj({pid: itemA.id}).then(resA => {
                    if(resA.success){
                        let arr1 = resA.result
                        this.qmImgList = []
                        arr1.forEach(itemB => {
                            getMoreUserSignLinkList({ids:itemB.blrid}).then(resB => {
                                if(resB.success && resB.result.length){
                                    if(resB.result[0].signLink == ''){
                                        this.qmImgList.push({
                                            ...itemB,
                                            url: null
                                        })
                                    } else {
                                        this.qmImgList.push({
                                            ...itemB,
                                            url: resB.result[0].signLink+'&aa='+Date.now()
                                        })
                                    }
                                }
                            })
                        })
                    }
                })
            });
            //console.log('打印签名',this.qmImgList)
        }
    }
}
</script>
<style lang="less">
@import url('../css/oaLess.css');
</style>
